<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nodes="http://www.nodes.de/nodes/1.0" xmlns:repo="xalan://offset.nodes.server.model.RepositoryUtils">
    <xsl:import href="template-basic.xsl"/>

    <xsl:output method="html"/>


    <xsl:template match="/" >
        <xsl:apply-templates select="nodes:springBean"/>
    </xsl:template>

    <xsl:template name="nodes_springBean.NAME" match="nodes:springBean/@NAME">
        <h1 n-id="{@jcr:uuid}" n-data="nodes:springBean/@NAME">
            <!--Name-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </h1>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_package" match="nodes:springBean/@nodes:package">
        <td n-id="{@jcr:uuid}" width="408" n-data="nodes:springBean/@nodes:package">
            <!--Package name-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_class" match="nodes:springBean/@nodes:class">
        <td n-id="{@jcr:uuid}" width="408" n-data="nodes:springBean/@nodes:class">
            <!--Class name-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_scope" match="nodes:springBean/@nodes:scope">
        <td n-id="{@jcr:uuid}" width="408" n-data="nodes:springBean/@nodes:scope">
            <!--The scope-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_description" match="nodes:springBean/nodes:description">
        <div n-component-id="{@jcr:uuid}" n-data="nodes:springBean/nodes:description">
            <!--xsl:call-template name="writePageContent"/-->
        </div>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springString.NAME" match="nodes:springBean/nodes:springString/@NAME">
        <td n-id="{@jcr:uuid}" width="20%" n-data="nodes:springBean/nodes:springString/@NAME">
            <!--The name-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springString.nodes_value" match="nodes:springBean/nodes:springString/@nodes:value">
        <td n-id="{@jcr:uuid}" width="23%" n-data="nodes:springBean/nodes:springString/@nodes:value">
            <!--The value-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springString.nodes_description" match="nodes:springBean/nodes:springString/@nodes:description">
        <td n-id="{@jcr:uuid}" width="31%" n-data="nodes:springBean/nodes:springString/@nodes:description">
            <!--An optional description-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springString.nodes_key" match="nodes:springBean/nodes:springString/@nodes:key">
        <td n-id="{@jcr:uuid}" width="25%" n-data="nodes:springBean/nodes:springString/@nodes:key">
            <!--Key, if property in map-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springString" match="nodes:springBean/nodes:springString">
        <tr valign="top" n-id="{@jcr:uuid}" n-data="nodes:springBean/nodes:springString">
            <xsl:for-each select="@NAME">
                <xsl:call-template name="nodes_springBean.nodes_springString.NAME"/>
            </xsl:for-each>
            <xsl:for-each select="@nodes:value">
                <xsl:call-template name="nodes_springBean.nodes_springString.nodes_value"/>
            </xsl:for-each>
            <xsl:for-each select="@nodes:description">
                <xsl:call-template name="nodes_springBean.nodes_springString.nodes_description"/>
            </xsl:for-each>
            <xsl:for-each select="@nodes:key">
                <xsl:call-template name="nodes_springBean.nodes_springString.nodes_key"/>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springReference.NAME" match="nodes:springBean/nodes:springReference/@NAME">
        <td n-id="{@jcr:uuid}" width="20%" n-data="nodes:springBean/nodes:springReference/@NAME">
            <!--The name-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springReference.nodes_value" match="nodes:springBean/nodes:springReference/@nodes:value">
        <td n-id="{@jcr:uuid}" width="23%" n-data="nodes:springBean/nodes:springReference/@nodes:value">
            <!--The reference value-->
            <xsl:call-template name="hyperlink-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springReference.nodes_description" match="nodes:springBean/nodes:springReference/@nodes:description">
        <td n-id="{@jcr:uuid}" width="24%" n-data="nodes:springBean/nodes:springReference/@nodes:description">
            <!--An optional description-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springReference.nodes_key" match="nodes:springBean/nodes:springReference/@nodes:key">
        <td n-id="{@jcr:uuid}" width="19%" n-data="nodes:springBean/nodes:springReference/@nodes:key">
            <!--Key, if property in map-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springReference" match="nodes:springBean/nodes:springReference">
        <tr valign="top" n-id="{@jcr:uuid}" class="container" n-data="nodes:springBean/nodes:springReference">
            <xsl:for-each select="@NAME">
                <xsl:call-template name="nodes_springBean.nodes_springReference.NAME"/>
            </xsl:for-each>
            <xsl:for-each select="@nodes:value">
                <xsl:call-template name="nodes_springBean.nodes_springReference.nodes_value"/>
            </xsl:for-each>
            <xsl:choose>
                <xsl:when test="@nodes:description">
                    <xsl:for-each select="@nodes:description">
                        <xsl:call-template name="nodes_springBean.nodes_springReference.nodes_description"/>
                    </xsl:for-each>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="nodes_springBean.nodes_springReference.nodes_description"/>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:choose>
                <xsl:when test="@nodes:key">
                    <xsl:for-each select="@nodes:key">
                        <xsl:call-template name="nodes_springBean.nodes_springReference.nodes_key"/>
                    </xsl:for-each>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="nodes_springBean.nodes_springReference.nodes_key"/>
                </xsl:otherwise>
            </xsl:choose>
            <td width="12%" class="action">
                <xsl:call-template name="invokeAction">
                    <xsl:with-param name="actionName">referenceRowMenu</xsl:with-param>
                </xsl:call-template>
                Action
            </td>
        </tr>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springBean.NAME" match="nodes:springBean/nodes:springBean/@NAME">
        <!--The name of the child bean-->
        <a href="/nodes/registry?ref={../@jcr:uuid}" n-data="nodes:springBean/nodes:springBean/@NAME">
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </a>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springBean.nodes_class" match="nodes:springBean/nodes:springBean/@nodes:class">
        <td n-id="{@jcr:uuid}" width="80%" n-data="nodes:springBean/nodes:springBean/@nodes:class">
            <!--The class.-->
            <xsl:call-template name="value-of">
                <xsl:with-param name="input" select="."/>
            </xsl:call-template>
        </td>
    </xsl:template>

    <xsl:template name="nodes_springBean.nodes_springBean" match="nodes:springBean/nodes:springBean">
        <tr valign="top" n-id="{@jcr:uuid}" n-data="nodes:springBean/nodes:springBean">
            <td width="20%">                
                <xsl:for-each select="@NAME">
                    <xsl:call-template name="nodes_springBean.nodes_springBean.NAME"/>
                </xsl:for-each>
            </td>
            <xsl:for-each select="@nodes:class">
                <xsl:call-template name="nodes_springBean.nodes_springBean.nodes_class"/>
            </xsl:for-each>
        </tr>
    </xsl:template>

    <xsl:template name="nodes_springBean" match="nodes:springBean">
        <div n-schema="nodes:springBean" n-id="{@jcr:uuid}" n-data="nodes:springBean">
            <xsl:for-each select="@NAME">
                <xsl:call-template name="nodes_springBean.NAME"/>
            </xsl:for-each>
            <table width="524">
                <tr valign="top">
                    <td width="116" class="label">                        Package
                    </td>
                    <xsl:for-each select="@nodes:package">
                        <xsl:call-template name="nodes_springBean.nodes_package"/>
                    </xsl:for-each>
                </tr>
                <tr valign="top">
                    <td width="116" class="label">                        Class
                    </td>
                    <xsl:for-each select="@nodes:class">
                        <xsl:call-template name="nodes_springBean.nodes_class"/>
                    </xsl:for-each>
                </tr>
                <tr valign="top">
                    <td width="116" class="label">                        Scope
                    </td>
                    <xsl:for-each select="@nodes:scope">
                        <xsl:call-template name="nodes_springBean.nodes_scope"/>
                    </xsl:for-each>
                </tr>
            </table>
            <p>            </p>
            <xsl:for-each select="nodes:description">
                <xsl:call-template name="nodes_springBean.nodes_description"/>
            </xsl:for-each>
            <xsl:if test="nodes:springString">
                <div>
                    <h2>                    String properties
                    </h2>
                    <table width="100%">
                        <tr valign="top">
                            <td width="20%" class="label">                            Name
                            </td>
                            <td width="23%" class="label">                            Value
                            </td>
                            <td width="31%" class="label">                            Description
                            </td>
                            <td width="25%" class="label">                            Key
                            </td>
                        </tr>
                        <xsl:for-each select="nodes:springString">
                            <xsl:call-template name="nodes_springBean.nodes_springString"/>
                        </xsl:for-each>
                    </table>
                </div>
            </xsl:if>
            <xsl:if test="nodes:springReference">
                <div>
                    <h2>                    Reference properties
                    </h2>
                    <table width="100%">
                        <tr valign="top">
                            <td width="20%" class="label">                            Name
                            </td>
                            <td width="23%" class="label">                            Value
                            </td>
                            <td width="24%" class="label">                            Description
                            </td>
                            <td width="19%" class="label">                            Key
                            </td>
                            <td class="commandLink" width="12%">
                                <xsl:call-template name="invokeAction">
                                    <xsl:with-param name="actionName">referenceMenu</xsl:with-param>
                                </xsl:call-template>
                                Action
                            </td>
                        </tr>
                        <xsl:for-each select="nodes:springReference">
                            <xsl:call-template name="nodes_springBean.nodes_springReference"/>
                        </xsl:for-each>
                    </table>
                </div>
            </xsl:if>
            <xsl:if test="nodes:springBean">
                <div>
                    <h2>                    Child beans
                    </h2>
                    <table width="100%">
                        <tr valign="top">
                            <td width="20%" class="label">                            Name
                            </td>
                            <td width="80%" class="label">                            Class
                            </td>
                        </tr>
                        <xsl:for-each select="nodes:springBean">
                            <xsl:call-template name="nodes_springBean.nodes_springBean"/>
                        </xsl:for-each>
                    </table>
                </div>
            </xsl:if>
        </div>
    </xsl:template>

</xsl:stylesheet>
